package com.jk.controller;

import com.jk.entity.ClothEntity;
import com.jk.entity.UserEntity;
import com.jk.entity.Payment;
import com.jk.entity.cartOrderEntity;
import com.jk.service.CartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

/**
 * @详细介绍类情况.
 * @ClassName CartController
 * @Author 王倚天
 * @Date 2022/6/1
 * @Version 1.0
 */
@RestController
@RequestMapping("cart")
public class CartController {
    @Autowired
    private CartService cartService;


    /**
     * @方法名称:查询购物车
     * @名字 王倚天

     * @返回值 java.util.List<com.jk.entity.ShopCartEntity>
     * @异常
     * @时间 2022/5/31 16:02
     */
    @RequestMapping("findShopCart")
    public List<ClothEntity> findShopCart(){
        return cartService.findShopCart();
    }

    /**
     * @方法名称:删除购物车商品
     * @名字 王倚天
     * @param id
     * @返回值 void
     * @异常
     * @时间 2022/5/31 20:39
     */
    @RequestMapping("deleteById")
    public void deleteById(@RequestParam Integer id){
        cartService.deleteById(id);
    }


    /**
     * @方法名称:批量删除购物车
     * @名字 王倚天
     * @param ids
     * @返回值 void
     * @异常
     * @时间 2022/6/1 14:21
     */
    @RequestMapping(value = "deleteByIds")
    public void deleteByIds(@RequestParam String[] ids){
        cartService.deleteByIds(ids);
    }
    
    /**
     * @方法名称:回显 购物车
     * @名字 王倚天
     * @param id 
     * @返回值 com.jk.entity.ClothEntity
     * @异常 
     * @时间 2022/6/6 19:45
     */
    @RequestMapping(value = "getcartById")
    public ClothEntity getcartById(@RequestParam Integer id){
        return cartService.getcartById(id);
    }


    /**
     * @方法名称:修改
     * @名字 王倚天
     * @param cloth 
     * @返回值 void
     * @异常 
     * @时间 2022/6/6 19:52
     */
    @RequestMapping(value = "updateById")
    public void updateById(@RequestBody ClothEntity cloth){
         cartService.updateById(cloth);
    }

    /**
     * @方法名称:购物车提交订单
     * @名字 王倚天
     * @param sumprice
 * @param ids
     * @返回值 void
     * @异常
     * @时间 2022/6/7 9:54
     */
    @RequestMapping(value = "submitOrder")
    public void submitOrder(@RequestParam Integer sumprice,@RequestParam String[] ids){
        cartService.submitOrder(sumprice,ids);
    }


    /**
     *订单详细信息
     * @return
     */
    @RequestMapping(value = "queryOrder")
    public List<Payment> queryOrder(){
        return  cartService.queryOrder();
    }



}
